/**
* Field consumer that shows the value of specified attribute to GUI
**/
jsx3.Class.defineClass(
	"ux.cdb.admin.dataautomate.FieldConsumer",
	jsx3.gui.Block,
	[ux.cdb.admin.dataautomate.IDataConsumer],
	function (block) {

		/**
		* instance initializer
		* @param strName {String} unique name distinguishing this object from all other JSX GUI objects in the JSX application
		* @param vntLeft {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntTop {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntWidth {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param vntHeight {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
		* @param strHTML {String} Text/HTML markup to place in the jsx3.gui.Block instance
		*/
		block.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML) {
			//call constructor for super class (the super expects the name of the object and the function that it is an instance of)
			this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
		};

		block.prototype.onSetParent = function(parent) {
			var lbl = this.getDescendantOfName("lblValue");
            this.getDescendantOfName("lblName").setTextAlign(jsx3.gui.Block.ALIGNRIGHT);
			lbl.oldSetText = lbl.setText;
			lbl.setText = function(text,bRepaint) {
				return this.oldSetText(text,bRepaint);
			}

			var ret = this.jsxsuper(parent);
			var me = this;
			setTimeout(function() {
				me.registerConsumer();
			},0);
			return ret;
		}
		
		block.prototype.applyData = function(data) {
			var me = this;
			var text = data[this.uxdataatt];
            if(text === null || text === undefined) {
                text = "";
            }
			if(me.formatHandler){
				var fn = jsx3.eval("var fn = " + me.formatHandler + "; fn;");
				text = fn(text);
			}
			this.getDescendantOfName("lblValue").setText(text,true);
		}
		

	});